package com.mialab.servlet_demo;

import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LifeServlet
 */
@WebServlet("/LifeServlet")
public class LifeServlet extends HttpServlet {
	
    public LifeServlet() {
    	System.out.println(this.getClass().getName() + "的构造方法被调用");        
    }

	public void init(ServletConfig config) throws ServletException {
		System.out.println(this.getClass().getName() + "的init()方法被调用");
	}

	public void destroy() {
		System.out.println(this.getClass().getName() + "的destroy()方法被调用");
	}

//	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		System.out.println(this.getClass().getName() + "的service()方法被调用...");
//	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.getWriter().append("Served at: ").append(request.getContextPath());
		System.out.println(this.getClass().getName() + "的doGet()方法被调用");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}